#ifndef _PANEL_H_
#define _PANEL_H_

#ifdef _WIN32
#pragma once
#endif

// 04.03.12 - Matthew Brews - Original Creation.

#include <d3dx9.h>
#include <map>
#include <string>

#include "windowbounds.h"
#include "constants.h"

using std::map;
using std::string;
using std::pair;

class CPanel
{
public:
    CPanel();
    virtual ~CPanel();

    float getPositionLeft() const;
    float getPositionTop() const;
    float getPositionRight() const;
    float getPositionBottom() const;
    float getHeight() const;
    float getWidth() const;

    void setHeight(float height);
    void setWidth(float width);
    void setSize(float height, float width);
    void setPosition(float left, float top, float right, float bottom);
    
    float getMarginLeft() const;
    float getMarginTop() const;
    float getMarginRight() const;
    float getMarginBottom() const;

    void setMarginLeft(float left);
    void setMarginTop(float top);
    void setMarginRight(float right);
    void setMarginBottom(float bottom);
    void setMargin(float left, float top, float right, float bottom);

    float getPaddingLeft() const;
    float getPaddingTop() const;
    float getPaddingRight() const;
    float getPaddingBottom() const;

    void setPaddingLeft(float left);
    void setPaddingTop(float top);
    void setPaddingRight(float right);
    void setPaddingBottom(float bottom);
    void setPadding(float left, float top, float right, float bottom);

    void setParent(CPanel *pParent);
    CPanel *getParent() const;
    void addChild(const string &szReferenceName, CPanel *pChild);
    void removeChild(CPanel *pChild);
    const map<string, CPanel*> &getChildren() const;
    int getChildrenCount() const;
    CPanel *getChild(const string &szReferenceName) const;

    float getRed() const;
    float getGreen() const;
    float getBlue() const;
    float getAlpha() const;
    D3DCOLORVALUE getColour() const;

    void setColour(D3DCOLORVALUE colour);
    void setColour(float red, float green, float blue);
    void setColour(float red, float green, float blue, float alpha);

    void hide();
    void show();
    bool isVisible() const;

    virtual void render();
    void renderChildren();
private:
    CWindowbounds m_margin;
    CWindowbounds m_padding;

    CPanel *m_pParent;
    map<string, CPanel*> m_arrChildren;

    CWindowbounds m_position;

    float m_fHeight;
    float m_fWidth;
    bool m_bVisible;

    D3DCOLORVALUE m_colour;
};

#endif